﻿create function AllTimecardsUpToDate(@cutoffDate datetime)
returns bit
as
begin
declare @cntEntered int
declare @cntAll int
select @cntEntered =count(*) from Users uu where uu.UserID in (
SELECT DISTINCT u.UserID
FROM         Users AS u INNER JOIN
                      EntryLog AS e ON u.UserID = e.UserID
WHERE     (e.EntryDate >= @cutoffDate) AND (u.IsActive = 1)
)
select @cntAll =count(*) from Users uu where uu.IsActive = 1
if (@cntAll = @cntEntered)
	return 1
return 0
end